﻿using Microsoft.EntityFrameworkCore.Migrations;
using TiaoTaoHelper.Wtm.Units.EFCore;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 用户岗位岗位角色增加唯一约束 : TransactionalMigration
    {
        /// <inheritdoc />
        protected override void UpWithTransaction(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_SysUserJobPosition_UserId",
                table: "SysUserJobPosition");

            migrationBuilder.DropIndex(
                name: "IX_SysJobPositionRole_JobPositionId",
                table: "SysJobPositionRole");

            migrationBuilder.CreateIndex(
                name: "IX_SysUserJobPosition_UserId_JobPositionId",
                table: "SysUserJobPosition",
                columns: new[] { "UserId", "JobPositionId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_SysJobPositionRole_JobPositionId_RoleId",
                table: "SysJobPositionRole",
                columns: new[] { "JobPositionId", "RoleId" },
                unique: true);
        }

        /// <inheritdoc />
        protected override void DownWithTransaction(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_SysUserJobPosition_UserId_JobPositionId",
                table: "SysUserJobPosition");

            migrationBuilder.DropIndex(
                name: "IX_SysJobPositionRole_JobPositionId_RoleId",
                table: "SysJobPositionRole");

            migrationBuilder.CreateIndex(
                name: "IX_SysUserJobPosition_UserId",
                table: "SysUserJobPosition",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_SysJobPositionRole_JobPositionId",
                table: "SysJobPositionRole",
                column: "JobPositionId");
        }
    }
}
